package com.sisyphus.tron.persistence;

import java.util.List;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

@Dao
public interface TronDao {

    /**
     * 所有账号
     */
    @Query("SELECT * FROM tron_account")
    List<AccountEntity> allAccount();


    /**
     * 插入一个地址
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void addAccount(AccountEntity addressEntity);


    /**
     * 根据地址找到
     */
    @Query("SELECT * FROM tron_account WHERE address = :address")
    AccountEntity findByAddress(String address);

    /**
     * 根据地址和密码找到
     */
    @Query("SELECT * FROM tron_account WHERE address = :address AND password = :password")
    AccountEntity findByAddressAndPassword(String address, String password);

    /**
     * 删除地址
     */
    @Delete
    void deleteAccount(AccountEntity addressEntity);

    /**
     * 修改
     */
    @Update
    void update(AccountEntity accountEntity);

}
